package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 中医体质判定-阴虚质
 * 
 * @author houyuchun
 * 
 */
public class YinxzBodyJudgeActivity extends AbstractControlActivity implements
		OnClickListener {

	// 文件创建日期
	private String createDate;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_body_judge_yinxuzhi);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addRadioGroupView(R.id.rad_yinxz_1, "阴虚质发热");
		addRadioGroupView(R.id.rad_yinxz_2, "阴虚质脸上发热");
		addRadioGroupView(R.id.rad_yinxz_3, "阴虚质唇干");
		addRadioGroupView(R.id.rad_yinxz_4, "阴虚质口唇");
		addRadioGroupView(R.id.rad_yinxz_5, "阴虚质便秘");
		addRadioGroupView(R.id.rad_yinxz_6, "阴虚质面部偏红");
		addRadioGroupView(R.id.rad_yinxz_7, "阴虚质眼睛干涩");
		addRadioGroupView(R.id.rad_yinxz_8, "阴虚质口干");

		setButtonListener(this, R.id.btn_next, R.id.btn_back);

		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		controlManager.toControl();

	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮ID
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_next:
			controlManager.toProperties();
			// 保存阴虚质转化分到properties文件
			saveBodyJudgeScore(createDate, "阴虚质", R.id.rad_yinxz_1,
					R.id.rad_yinxz_2, R.id.rad_yinxz_3, R.id.rad_yinxz_4,
					R.id.rad_yinxz_5, R.id.rad_yinxz_6, R.id.rad_yinxz_7,
					R.id.rad_yinxz_8);
			// 下一步按钮
			intent.setClass(this, YxzBodyJudgeActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			finish();
			break;
		case R.id.btn_back:
			finish();
			break;
		default:
			break;
		}
	}
}